package com.java.module.chat.controller.api;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.java.common.service.ApiTokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.java.module.chat.service.IChatGroupService;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 聊天模块：群聊Controller
 * 
 * @author Administrator
 * @date 2023-02-16
 */
@ApiSort(2000)
@Api(tags = "群聊")
@RestController("ApiChatGroupController")
@RequestMapping("/chat/chatGroup")
public class ChatGroupController {

    @Autowired
    IChatGroupService chatGroupService;

    @Autowired
    private ApiTokenService tokenService;


    @ApiOperationSupport(order = 10)
    @ApiOperation("创建群聊")
    @GetMapping("/createGroup/{uids}")
    public Long getMessageList(@Validated @NotNull @PathVariable("uids") Long[] uids) {
        Long loginUserId = tokenService.getLoginUserId();
        return chatGroupService.createGroup(loginUserId,uids);
    }

    @ApiOperationSupport(order = 10)
    @ApiOperation("添加群聊人员")
    @GetMapping("/addGroupUser")
    public int addGroupUser(@Validated @NotNull Long gid,@Validated @NotBlank String idNumber) {
        Long loginUserId = tokenService.getLoginUserId();
        return chatGroupService.addGroupUser(loginUserId,gid,idNumber);
    }
}